package Operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by xiebang
 * Description
 * User:小谢
 * Date:2021-09-21
 * Time:21:11
 */
public class ReturnOperation implements IOperation{

    @Override
    public void work(BookList bookList) {
        System.out.println("返回图书！");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要返回图书的名字");
        String name = scanner.nextLine();
        int size = bookList.getBookSize();

        for (int i = 0; i < size; i++) {
            Book book = bookList.getBook(i);

            Book book1 = bookList.getBook(size - 1);
            if (book.getName().equals(name)){
                book1.setState(false);
                System.out.println("归还成功");
                return;
            }

        }
        System.out.println("没有该图书");
    }
}
